﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Text;
// Based off CDC's Epi Info 7 IDbDriver interface; see http://epiinfo.codeplex.com

namespace NutriStat.Data
{
    public interface IDbDriver
    {
        #region Properties
        
        string FullName
        {
            get;
        }
        
        string DbName
        {
            get;
            set;
        }

        
        string ConnectionString
        {
            get;
            set;
        }

        string DataSource
        {
            get;
        }
        
        string ConnectionDescription
        {
            get;
        }
        #endregion Properties        

        #region Methods
        bool TestConnection();
        void CreateTable(string tableName, List<TableColumn> columns);
        List<string> GetTableNames();                
        int GetTableCount();
        DataTable Select(Query selectQuery);
        DataTable Select(Query selectQuery, DataTable table);
        bool ColumnExists(string tableName, string columnName);
        int ExecuteNonQuery(Query nonQueryStatement);
        int ExecuteNonQuery(Query nonQueryStatement, IDbTransaction transaction);
        object ExecuteScalar(Query scalarStatement);
        object ExecuteScalar(Query scalarStatement, IDbTransaction transaction);
        bool DeleteTable(string tableName);
        bool TableExists(string tableName);
        
        DataTable GetTableData(string tableName);
        DataTable GetTableData(string tableName, string columnNames);
        DataTable GetTableData(string tableName, string columnNames, string sortCriteria);
        IDataReader GetTableDataReader(string tableName);
        IDataReader ExecuteReader(Query selectQuery);
        List<string> GetTableColumnNames(string tableName);
        DataView GetTextColumnNames(string tableName);
        IDbTransaction OpenTransaction();
        IDbTransaction OpenTransaction(IsolationLevel isolationLevel);
        void CloseTransaction(IDbTransaction transaction);
        void Update(DataTable dataTable, string tableName, Query insertQuery, Query updateQuery);
        void Dispose();
        Query CreateQuery(string ansiSqlStatement);
        
        string IdentifyDatabase();
        string GetDbSpecificColumnType(GenericDbColumnType dataType);
        string InsertInEscape(string str);
        List<string> InsertInEscape(List<string> strings);
        string FormatDate(DateTime dt);
        string FormatDateTime(DateTime dt);
        string FormatTime(DateTime time);
        #endregion Methods
    }
}
